﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Storm.TextEditor.Editor.CodeCompletion
{
	/// <summary>
	/// Represents the default completion data holder.
	/// </summary>
	public class DefaultCompletionData
		: ICompletionData
	{
		#region Fields

		private int     imageIndex  = 0;
		private string  text        = "";
		private string  description = "";

		#endregion

		#region Properties

		/// <summary>
		/// Gets or sets the index of the image.
		/// </summary>
		/// <value>The index of the image.</value>
		public int ImageIndex
		{
			get { return imageIndex; }
			set { imageIndex = value; }
		}

		/// <summary>
		/// Gets or sets the text.
		/// </summary>
		/// <value>The text.</value>
		public string Text
		{
			get { return text; }
			set { text = value; }
		}

		/// <summary>
		/// Gets or sets the description.
		/// </summary>
		/// <value>The description.</value>
		public string Description
		{
			get { return description; }
			set { description = value; }
		}

		#endregion

		#region Methods

		#region Public

		/// <summary>
		/// Compares this instance to the given instance.
		/// </summary>
		/// <param name="obj">The instance to compare to.</param>
		/// <returns></returns>
		public int CompareTo(object obj)
		{
			if (obj is ICompletionData)
			{
				ICompletionData completionData = (ICompletionData)obj;
				return this.Text.CompareTo(completionData.Text);
			}
			else
				throw new ArgumentNullException("obj");
		}

		#endregion

		#endregion

		/// <summary>
		/// Initializes a new instance of the <see cref="DefaultCompletionData"/> class.
		/// </summary>
		public DefaultCompletionData()
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="DefaultCompletionData"/> class.
		/// </summary>
		/// <param name="imageIndex">Index of the image.</param>
		/// <param name="text">The text.</param>
		/// <param name="description">The description.</param>
		public DefaultCompletionData(int imageIndex, string text, string description)
		{
			this.ImageIndex = imageIndex;
			this.Text = text;
			this.Description = description;
		}
	}
}
